3.1.8 \(\int x \tan ^2(a+b x) \, dx\) [8]

Optimal. Leaf size=30 \[ -\frac {x^2}{2}+\frac {\log (\cos (a+b x))}{b^2}+\frac {x \tan (a+b x)}{b} \]

[Out]

-1/2*x^2+ln(cos(b*x+a))/b^2+x*tan(b*x+a)/b

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 30, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.300, Rules used = {3801, 3556, 30} \begin {gather*} \frac {\log (\cos (a+b x))}{b^2}+\frac {x \tan (a+b x)}{b}-\frac {x^2}{2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[x*Tan[a + b*x]^2,x]

[Out]

-1/2*x^2 + Log[Cos[a + b*x]]/b^2 + (x*Tan[a + b*x])/b

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3801

Int[((c_.) + (d_.)*(x_))^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[b*(c + d*x)^m*((b*Tan[e
 + f*x])^(n - 1)/(f*(n - 1))), x] + (-Dist[b*d*(m/(f*(n - 1))), Int[(c + d*x)^(m - 1)*(b*Tan[e + f*x])^(n - 1)
, x], x] - Dist[b^2, Int[(c + d*x)^m*(b*Tan[e + f*x])^(n - 2), x], x]) /; FreeQ[{b, c, d, e, f}, x] && GtQ[n,
1] && GtQ[m, 0]

Rubi steps

\begin {align*} \int x \tan ^2(a+b x) \, dx &=\frac {x \tan (a+b x)}{b}-\frac {\int \tan (a+b x) \, dx}{b}-\int x \, dx\\ &=-\frac {x^2}{2}+\frac {\log (\cos (a+b x))}{b^2}+\frac {x \tan (a+b x)}{b}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.21, size = 43, normalized size = 1.43 \begin {gather*} -\frac {x^2}{2}+\frac {\log (\cos (a+b x))}{b^2}+\frac {x \sec (a) \sec (a+b x) \sin (b x)}{b}+\frac {x \tan (a)}{b} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[x*Tan[a + b*x]^2,x]

[Out]

-1/2*x^2 + Log[Cos[a + b*x]]/b^2 + (x*Sec[a]*Sec[a + b*x]*Sin[b*x])/b + (x*Tan[a])/b

________________________________________________________________________________________

Maple [A]
time = 0.08, size = 40, normalized size = 1.33

method result size
norman \(\frac {x \tan \left (b x +a \right )}{b}-\frac {x^{2}}{2}-\frac {\ln \left (1+\tan ^{2}\left (b x +a \right )\right )}{2 b^{2}}\) \(34\)
default \(-\frac {x^{2}}{2}+\frac {\left (b x +a \right ) \tan \left (b x +a \right )+\ln \left (\cos \left (b x +a \right )\right )-a \tan \left (b x +a \right )}{b^{2}}\) \(40\)
risch \(-\frac {x^{2}}{2}-\frac {2 i x}{b}-\frac {2 i a}{b^{2}}+\frac {2 i x}{b \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}+\frac {\ln \left ({\mathrm e}^{2 i \left (b x +a \right )}+1\right )}{b^{2}}\) \(57\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x*tan(b*x+a)^2,x,method=_RETURNVERBOSE)

[Out]

-1/2*x^2+1/b^2*((b*x+a)*tan(b*x+a)+ln(cos(b*x+a))-a*tan(b*x+a))

________________________________________________________________________________________

Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 214 vs. \(2 (28) = 56\).
time = 0.53, size = 214, normalized size = 7.13 \begin {gather*} \frac {2 \, {\left (b x + a - \tan \left (b x + a\right )\right )} a - \frac {{\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right )^{2} + {\left (b x + a\right )}^{2} \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, {\left (b x + a\right )}^{2} \cos \left (2 \, b x + 2 \, a\right ) + {\left (b x + a\right )}^{2} - {\left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right )} \log \left (\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1\right ) - 4 \, {\left (b x + a\right )} \sin \left (2 \, b x + 2 \, a\right )}{\cos \left (2 \, b x + 2 \, a\right )^{2} + \sin \left (2 \, b x + 2 \, a\right )^{2} + 2 \, \cos \left (2 \, b x + 2 \, a\right ) + 1}}{2 \, b^{2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*tan(b*x+a)^2,x, algorithm="maxima")

[Out]

1/2*(2*(b*x + a - tan(b*x + a))*a - ((b*x + a)^2*cos(2*b*x + 2*a)^2 + (b*x + a)^2*sin(2*b*x + 2*a)^2 + 2*(b*x
+ a)^2*cos(2*b*x + 2*a) + (b*x + a)^2 - (cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1)*log
(cos(2*b*x + 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1) - 4*(b*x + a)*sin(2*b*x + 2*a))/(cos(2*b*x
+ 2*a)^2 + sin(2*b*x + 2*a)^2 + 2*cos(2*b*x + 2*a) + 1))/b^2

________________________________________________________________________________________

Fricas [A]
time = 0.39, size = 38, normalized size = 1.27 \begin {gather*} -\frac {b^{2} x^{2} - 2 \, b x \tan \left (b x + a\right ) - \log \left (\frac {1}{\tan \left (b x + a\right )^{2} + 1}\right )}{2 \, b^{2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*tan(b*x+a)^2,x, algorithm="fricas")

[Out]

-1/2*(b^2*x^2 - 2*b*x*tan(b*x + a) - log(1/(tan(b*x + a)^2 + 1)))/b^2

________________________________________________________________________________________

Sympy [A]
time = 0.08, size = 41, normalized size = 1.37 \begin {gather*} \begin {cases} - \frac {x^{2}}{2} + \frac {x \tan {\left (a + b x \right )}}{b} - \frac {\log {\left (\tan ^{2}{\left (a + b x \right )} + 1 \right )}}{2 b^{2}} & \text {for}\: b \neq 0 \\\frac {x^{2} \tan ^{2}{\left (a \right )}}{2} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*tan(b*x+a)**2,x)

[Out]

Piecewise((-x**2/2 + x*tan(a + b*x)/b - log(tan(a + b*x)**2 + 1)/(2*b**2), Ne(b, 0)), (x**2*tan(a)**2/2, True)
)

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 182 vs. \(2 (28) = 56\).
time = 0.70, size = 182, normalized size = 6.07 \begin {gather*} -\frac {b^{2} x^{2} \tan \left (b x\right ) \tan \left (a\right ) - b^{2} x^{2} + 2 \, b x \tan \left (b x\right ) + 2 \, b x \tan \left (a\right ) - \log \left (\frac {4 \, {\left (\tan \left (b x\right )^{4} \tan \left (a\right )^{2} - 2 \, \tan \left (b x\right )^{3} \tan \left (a\right ) + \tan \left (b x\right )^{2} \tan \left (a\right )^{2} + \tan \left (b x\right )^{2} - 2 \, \tan \left (b x\right ) \tan \left (a\right ) + 1\right )}}{\tan \left (a\right )^{2} + 1}\right ) \tan \left (b x\right ) \tan \left (a\right ) + \log \left (\frac {4 \, {\left (\tan \left (b x\right )^{4} \tan \left (a\right )^{2} - 2 \, \tan \left (b x\right )^{3} \tan \left (a\right ) + \tan \left (b x\right )^{2} \tan \left (a\right )^{2} + \tan \left (b x\right )^{2} - 2 \, \tan \left (b x\right ) \tan \left (a\right ) + 1\right )}}{\tan \left (a\right )^{2} + 1}\right )}{2 \, {\left (b^{2} \tan \left (b x\right ) \tan \left (a\right ) - b^{2}\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(x*tan(b*x+a)^2,x, algorithm="giac")

[Out]

-1/2*(b^2*x^2*tan(b*x)*tan(a) - b^2*x^2 + 2*b*x*tan(b*x) + 2*b*x*tan(a) - log(4*(tan(b*x)^4*tan(a)^2 - 2*tan(b
*x)^3*tan(a) + tan(b*x)^2*tan(a)^2 + tan(b*x)^2 - 2*tan(b*x)*tan(a) + 1)/(tan(a)^2 + 1))*tan(b*x)*tan(a) + log
(4*(tan(b*x)^4*tan(a)^2 - 2*tan(b*x)^3*tan(a) + tan(b*x)^2*tan(a)^2 + tan(b*x)^2 - 2*tan(b*x)*tan(a) + 1)/(tan
(a)^2 + 1)))/(b^2*tan(b*x)*tan(a) - b^2)

________________________________________________________________________________________

Mupad [B]
time = 0.11, size = 35, normalized size = 1.17 \begin {gather*} -\frac {\frac {\ln \left ({\mathrm {tan}\left (a+b\,x\right )}^2+1\right )}{2}-b\,x\,\mathrm {tan}\left (a+b\,x\right )}{b^2}-\frac {x^2}{2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(x*tan(a + b*x)^2,x)

[Out]

- (log(tan(a + b*x)^2 + 1)/2 - b*x*tan(a + b*x))/b^2 - x^2/2

________________________________________________________________________________________